import React, { Component } from 'react';
import { ImageBackground, TextInput, View, Image, StatusBar, Text, TouchableOpacity, FlatList, RefreshControl, DeviceEventEmitter } from 'react-native';
import TabBarTitle from '../components/TabBarTitle';
import TabBarImage from '../components/TabBarImage';
import Colors from '../constants/Colors';
import { statusBarHeight, titleHeight, width, unitWidth } from '../constants/AdapterUtil';
import ScrollableTabView, { ScrollableTabBar, DefaultTabBar } from 'react-native-scrollable-tab-view';
import { LeftComponent, MyHeader } from '../components/MyHeader';
import { SubmitButton6 } from '../components/Button';
import MyListView from '../components/MyListView';
import { DeleteTextView, MyTextView } from '../components/MyTextView';
import { Rating, AirbnbRating } from 'react-native-elements';
import { api_order_workorder_newsDetail, api_order_workorder_newsList } from '../constants/HttpServices';
import { postFetch } from '../constants/HttpExtension';

export default class MessageDetailScreen extends Component {
    constructor(props) {
        super(props)
        this.id = this.props.navigation.getParam('id', -1)
        this.state = {
            info: {}
        }
    }

    componentDidMount() {
        this.getData();
    }

    componentWillUnmount() {

    }

    render() {
        return (
            <View style={{ flex: 1, backgroundColor: Colors.colorF5 }}>
                <MyHeader title='消息' leftImg={require('../res/ic_arrow_left.png')} leftClick={() => { this.props.navigation.pop() }} />
                <View style={{
                    justifyContent: 'center',
                    width: width, paddingHorizontal: 10 * unitWidth, paddingVertical: 15 * unitWidth, backgroundColor: Colors.white
                }}>
                    <View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
                        <Text style={{ fontWeight: 'bold', color: Colors.black, fontSize: 15 }}>{this.state.info.title}</Text>
                        <Text style={{ color: Colors.color99, fontSize: 15 }}>{this.state.info.createtime}</Text>
                    </View>
                    <MyTextView numberOfLines={3} style={{ color: Colors.color99, fontSize: 13, marginVertical: 8 * unitWidth }} content={this.state.info.content} />
                    <View style={{ backgroundColor: Colors.colorEF, width: width, alignSelf: 'center', height: 0.5, marginTop: 10 * unitWidth, position: 'absolute', bottom: 0 }} />
                </View>
            </View>
        )
    }

    //获取工单信息
    getData() {
        let params = {
            id: this.id,
        }
        postFetch(api_order_workorder_newsDetail, params, {
            success: (response) => {
                this.setState({
                    info: response.result,
                })
            },
            fail: (response) => {
                show(response.result.message);
            }
        })
    }
}
